package com.yami.shop.mystery.common.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yami.shop.common.bean.PageDTO;
import com.yami.shop.common.bean.PageVO;
import com.yami.shop.common.util.PageUtil;
import com.yami.shop.mystery.common.dao.CompoundRecordMapper;
import com.yami.shop.mystery.common.model.CompoundRecord;
import com.yami.shop.mystery.common.service.CompoundRecordServer;
import com.yami.shop.mystery.common.vo.CompoundRecordVo;
import com.yami.shop.security.common.bo.UserInfoInTokenBO;
import com.yami.shop.security.common.util.AuthUserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class CompoundRecordServerImpl extends ServiceImpl<CompoundRecordMapper, CompoundRecord> implements CompoundRecordServer {

    @Autowired
    private CompoundRecordMapper compoundRecordMapper;
//    @Autowired
//    private PersonnftFeignClient personnftFeignClient;

    @Override
    public PageVO<CompoundRecordVo> getCompoundPage(PageDTO pageDTO) {
        UserInfoInTokenBO userInfoInTokenBO = AuthUserContext.get();
        return PageUtil.doPage(pageDTO, () -> compoundRecordMapper.getCompoundPage(userInfoInTokenBO.getUserId()));
    }

    @Override
    public CompoundRecordVo getCompoundRecordDetail(int compoundRecordId) {
        CompoundRecordVo compoundRecordVO = compoundRecordMapper.getCompoundRecordDetail(compoundRecordId);
        String[] personNfts = compoundRecordVO.getExpendToken().split(",");
//        ServerResponseEntity<List<PersonNftVO>> personNftDataList = personnftFeignClient.getPersonNftDataList(Arrays.asList(personNfts));
//        compoundRecordVO.setCompoundDenoms(personNftDataList.getData());
        return compoundRecordVO;
    }
}
